//
//  LPZWYmMyTableViewCell.m
//  TestZhongWangYuan
//
//  Created by liuyingping on 2018/6/2.
//  Copyright © 2018年 刘应平. All rights reserved.
//

#import "LPZWYmMyTableViewCell.h"
#import "LPZWYContentView.h"
@implementation LPZWYmMyTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor themeGrayColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self layoutUI];
    }
    return self;
}

- (void)layoutUI{
    for (UIView *subView in self.subviews) {
        [subView removeFromSuperview];
    }
    
    NSArray *titles = @[@"我的专题", @"我的课程", @"我的收藏", @"我的考试" , @"修改密码"];
    NSArray *imageNames = @[@"my_topics", @"my_course", @"my_c", @"my_ex", @"icon_xgmm"];
    NSArray *contents = @[@"学习0个专题班", @"学习0门课程", @"共有0个收藏", @"有0门考试" , @"noContent"];
    NSArray *numbers = @[@"0", @"0", @"0", @"0" , @"0"];
    if (self.model) {
        numbers = @[self.model.myclasscount , self.model.mystudycoursecount, self.model.mycollectioncount, self.model.myexamcount , @"0"];
        contents = @[[NSString stringWithFormat:@"学习%@个专题班",self.model.myclasscount],[NSString stringWithFormat:@"学习%@门课程",self.model.mystudycoursecount], [NSString stringWithFormat:@"共有%@个收藏",self.model.mycollectioncount],[NSString stringWithFormat:@"共有%@门考试",self.model.myexamcount] , @"noContent"];
    }
    for (int i = 0; i < titles.count; i ++) {
        NSInteger zheng = i / 2;
        NSInteger yu = i % 2;
        LPZWYContentView *content = [[LPZWYContentView alloc] initWithFrame:CGRectMake([UIScreen zj_screenWith] / 2 * yu , zheng * 80 * [UIScreen zj_screenHScale], [UIScreen zj_screenWith] / 2, 80 * [UIScreen zj_screenHScale]) imageName:imageNames[i] title:titles[i] content:contents[i] number:numbers[i]];
        content.layer.borderWidth = 0.5;
        content.layer.borderColor = [UIColor themeGrayColor].CGColor;
        content.tag = i;
        content.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        [content addGestureRecognizer:tap];
        [self addSubview:content];
        
    }
}

- (void)tapClick:(UITapGestureRecognizer *)tap{
    if (self.delegate) {
        [self.delegate LPZWYmMyTableViewCell_click_index:tap.view.tag];
    }
}

- (void)setModel:(LPZWYMyDetailModel *)model{
    _model = model;
    [self layoutUI];
    
}


@end
